package model
{
	/**
	 * 地理信息节点
	 * 	  
	 **/
	public class GoogleGeoResult
	{
		private var xmlData:XML = null;
		
		public function GoogleGeoResult(xmlData:XML)
		{
			if ( isRightFormat(xmlData) )
			{
				this.xmlData = xmlData;
			}
			else
			{
				throw new Error("返回格式不正确!");
			}
		}
		
		public function getFormattedAddress():String
		{
			return String(this.xmlData.formatted_address);
		}
		
		private function isRightFormat(xmlData:XML):Boolean
		{
			return (xmlData.type != "" 
					|| xmlData.formatted_address != ""
					|| xmlData.geometry.location != "")
		}
		
		public function getType():String
		{
			return String(this.xmlData.type);
		}
		
		/**
		 *  返回经纬度
		 **/
		public function getLocation():Location
		{
			var item : Object = this.xmlData.geometry.location;			
			return new Location(String(item.lng), String(item.lat));
		}
	}
}